//
// Created by Champrin on 2022/10/28.
// 仅用作桂林电子科技大学2023赛季Evolution战队视觉组培训使用
//
#include <opencv2/opencv.hpp>

//为了能在被调函数中使用，所以设置成全局的
int bValue, gValue, rValue;//BGR各个通道的值
int rows = 256, cols = 256;//行数和列数
cv::Mat img = cv::Mat(rows, cols, CV_8UC3,
                      cv::Scalar(255, 255, 255)); //创建一个rows*cols 3通道16位无符号类型 每一个像素值都是(255,255,255)的Mat

void BGRCallBack(int, void *) {
    for (int i = 0; i < rows; i++){
        for (int j = 0; j < cols; j++){
            img.at<cv::Vec3b>(i, j)[0] = bValue;
            img.at<cv::Vec3b>(i, j)[1] = gValue;
            img.at<cv::Vec3b>(i, j)[2] = rValue;
        }
    }
    imshow("BGR", img);
}

int dsadascwae() {
    cv::namedWindow("BGR");
    imshow("BGR", img);
    cv::createTrackbar("B", "BGR", &bValue, 255, BGRCallBack, 0);
    cv::createTrackbar("G", "BGR", &gValue, 255, BGRCallBack, 0);
    cv::createTrackbar("R", "BGR", &rValue, 255, BGRCallBack, 0);
    cv::waitKey();
}

